#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define erro1 "Erro na string"
#define seps ", +*."

char* sepwords (char *str, char *delim, char **save_ptr)
{
  char *token;
  
  if (str == NULL)
    str = *save_ptr;

  /* Verifica os primeiros delimiadores.  */
  str += strspn (str, delim);
  if (*str == '\0'){
    *save_ptr = str;
    return NULL;
  }
  
  /* Encontra o final do token.  */
  
  token = str;
  str = strpbrk (token, delim);
  if (str == NULL)

  /* Caso em que eh o ultimo token da string.  */
  *save_ptr = strchr (token, '\0');
  else 
  {
    /* Retorna o token e faz *SAVE_PTR apontar para o elemento subsequente.  */
    *str = '\0';
    *save_ptr = str + 1;
  }
  return token;
  
}



int main(int argc, char** argv){
  
  char *string, * word, *ptr1;
   string = argv[1];
  
  word = sepwords(string, seps, &ptr1);
  while(word){
    printf("Palavras %s:\n", word);
    string= ptr1;
    word = sepwords(string, seps, &ptr1);
      
    system("pause");
  }
  
  printf("%s\n", string);
  system("pause");

}


